#define	_CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct BTNode
{
	char data;
	BTNode* left;
	BTNode* right;
};

BTNode* BinaryTreeCreate(const vector<char> v, int& pi)
{
	if (v[pi] == '*' || pi > v.size())
	{
		++pi;
		return nullptr;
	}

	BTNode* root = new BTNode;
	root->data = v[pi++];

	root->left = BinaryTreeCreate(v, pi);
	root->right = BinaryTreeCreate(v, pi);

	return root;
}

void LevelOrder(BTNode* root)
{
	queue<BTNode*> q;
	q.push(root);

	while (!q.empty())
	{
		int size = q.size();
		while (size--)
		{
			BTNode* front = q.front();
			cout << front->data << " ";
			q.pop();

			if (front->left)
			{
				q.push(front->left);
			}
			if (front->right)
			{
				q.push(front->right);
			}
		}
	}
}

void BinaryTreeDestory(BTNode* root)
{
	if (root == nullptr)
	{
		return;
	}

	BinaryTreeDestory(root->left);
	BinaryTreeDestory(root->right);
	delete root;
}

int main()
{
	vector<char> v;
	char ch;
	while (cin >> ch)
	{
		v.push_back(ch);
	}

	int pi = 0;
	BTNode* tree = BinaryTreeCreate(v, pi);

	if(tree != nullptr)
	{
		LevelOrder(tree);
	}

	return 0;
}